#include <lib.h>
#define dfs_add_file _dfs_add_file
#include <dfs.h>
#include <string.h>
#include <sys/stat.h>
#include <limits.h>
/*
 * Implementation of the library function for
 * the _dfs_add_file system call
 */

#if _ANSI
PUBLIC int dfs_add_file(const char *filepath)
#else
PUBLIC int dfs_add_file(filepath)
const char *filepath
#endif
{
	struct stat *st;
	int reply, path_size;
	message m;
	
	/* Testing if file exists */
	if (stat(filepath,st) != OK) return (ERROR);
	
	
	/* Set message to be sent */
	m.FILEPATH = (char *)filepath;
	path_size=strlen(filepath);
	if ( path_size > PATH_MAX || path_size <= 0 ) return(ERROR);
	m.FILEPATHLEN = path_size;
	
	/* Making the call */
	reply = _syscall(DFS,DFS_ADD_FILE,&m);
	
	/* Return results */
	return reply;
}
